package com.geostart.constructionland.system.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.geostar.constructionland.common.entity.lockInfo.JsydLockInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author chengan
 * @description 建设用地锁信息Mapper
 */
public interface JsydLockInfoMapper extends BaseMapper<JsydLockInfo>{

 //For Oracle
    @Select("select * from (select case\n" +
            "when t.xmmc = '流程信息案卷锁'then CONCAT(tt.xmmc,'(流程信息锁)')\n" +
            "else tt.xmmc end xmmc,t.lockid,t.ajid,t.czr,t.lock_time,t.unlock_time,t.redis_value,t.expire_time,\n" +
            "trunc(to_number((t.unlock_time-t.lock_time)* 24 * 60 * 60)) as lock_exist from jsyd_lock_info t left join jsyd_bpxx tt on t.ajid =tt.ywid )${ew.customSqlSegment}")

//     //For MySQL
//    @Select("select * from (select case\n" +
//            "when t.xmmc = '流程信息案卷锁'then CONCAT(null,'(流程信息锁)')\n" +
//            "else null end xmmc,t.lockid,t.ajid,t.czr,t.lock_time,t.unlock_time,t.redis_value,t.expire_time,\n" +
//            "(t.unlock_time-t.lock_time)* 24 * 60 * 60 as lock_exist from jsyd_lock_info t )temp ${ew.customSqlSegment}")
    IPage<JsydLockInfo> selectPageJsydLock(Page<JsydLockInfo> page, @Param(Constants.WRAPPER) Wrapper<JsydLockInfo> jsydInfoLock);
}
